package com.takepoints21.mobile.dialog;

import com.takepoints21.mobile.R;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class PostSocialDlg extends Dialog implements DialogInterface {
	
	private String textToPost;
	
	public PostSocialDlg(Context context) {
		super(context);
	}
	
	@Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.socialdialog);
        setTitle("โพสต์ข้อความไปยัง Social");
        setCancelable(true);
        setCanceledOnTouchOutside(true);
        
        final TextView txtPost = (TextView)findViewById(R.id.txtPost);
        txtPost.setText(getTextToPost());
        
        final Button btnPost = (Button)this.findViewById(R.id.btnPost);
        btnPost.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            	setTextToPost(String.valueOf(txtPost.getText()));
            	dismiss();
            }
        });
        
        final Button btnCancel = (Button)this.findViewById(R.id.btnCancel);
        btnCancel.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
            	setTextToPost(null);
            	dismiss();
            }
        });
	}

	public String getTextToPost() {
		return textToPost;
	}
	public void setTextToPost(String textToPost) {
		this.textToPost = textToPost;
	}
	
}
